1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"824.42">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #a71e12}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco
; min-height: 14.0px}
18 span
.s1
{color: #000000}
19 span
.s2
{color: #0019b7}
20 span
.s3
{color: #326f17}
21 span
.s4
{color: #606060}
22 span
.s5
{color: #0000ff}
23 span
.s6
{color: #a71e12}
24 span
.Apple-tab-span
{white-space:pre
}
28 <p class=
"p1"><b>Non-Realtime Synthesis
</b></p>
29 <p class=
"p2"><br></p>
30 <p class=
"p3">This documentation is initial.
</p>
31 <p class=
"p2"><br></p>
32 <p class=
"p3">SuperCollider
3 supports non-realtime synthesis through the use of binary files of OSC commands.
</p>
33 <p class=
"p2"><br></p>
34 <p class=
"p3">First create an OSC command file (i.e. a score)
</p>
35 <p class=
"p2"><br></p>
36 <p class=
"p4"><span class=
"s1">f =
</span><span class=
"s2">File
</span><span class=
"s1">(
</span>"Cmds.osc"<span class=
"s1">,
</span>"w"<span class=
"s1">);
</span></p>
37 <p class=
"p5"><br></p>
38 <p class=
"p6">// start a sine oscillator at
0.2 seconds.
</p>
39 <p class=
"p7">c = [
0.2, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1001,
0,
0]].asRawOSC;
</p>
40 <p class=
"p6"><span class=
"s1">f.write(c.size);
</span>// each bundle is preceeded by a
32 bit size.
</p>
41 <p class=
"p6"><span class=
"s1">f.write(c);
</span>// write the bundle data.
</p>
42 <p class=
"p5"><br></p>
43 <p class=
"p6">// stop sine oscillator at
3.0 seconds.
</p>
44 <p class=
"p7">c = [
3.0, [
<span class=
"s3">\n_free
</span>,
1001]].asRawOSC;
</p>
45 <p class=
"p7">f.write(c.size);
</p>
46 <p class=
"p7">f.write(c);
</p>
47 <p class=
"p5"><br></p>
48 <p class=
"p6">// scsynth stops processing immediately after the last command, so here is
</p>
49 <p class=
"p6">// a do-nothing command to mark the end of the command stream.
</p>
50 <p class=
"p7">c = [
3.2, [
<span class=
"s3">0</span>]].asRawOSC;
</p>
51 <p class=
"p7">f.write(c.size);
</p>
52 <p class=
"p7">f.write(c);
</p>
53 <p class=
"p5"><br></p>
54 <p class=
"p7">f.close;
</p>
55 <p class=
"p2"><br></p>
56 <p class=
"p6">// the 'NRTsine' SynthDef
</p>
58 <p class=
"p7"><span class=
"s2">SynthDef
</span>(
<span class=
"s4">"NRTsine"</span>,{
<span class=
"s2">arg
</span> freq =
440;
</p>
59 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"s2">Out
</span>.ar(
0,
</p>
60 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span> <span class=
"s2">SinOsc
</span>.ar(freq,
0,
0.2)
</p>
61 <p class=
"p7"><span class=
"Apple-tab-span"> </span>)
</p>
62 <p class=
"p7">}).writeDefFile;
</p>
64 <p class=
"p2"><br></p>
65 <p class=
"p3">then on the command line (i.e. in Terminal):
</p>
66 <p class=
"p2"><br></p>
67 <p class=
"p3">./scsynth -N Cmds.osc _ NRTout.aiff
44100 AIFF int16
</p>
68 <p class=
"p2"><br></p>
69 <p class=
"p3">The command line arguments are:
</p>
70 <p class=
"p2"><br></p>
71 <p class=
"p3"><span class=
"Apple-converted-space"> </span>-N
<cmd-filename
> <input-filename
> <output-filename
> <sample-rate
> <header-format
> <sample-format
> <span class=
"Apple-tab-span"> </span><...other scsynth arguments
></p>
72 <p class=
"p2"><br></p>
73 <p class=
"p3">If you do not need an input sound file, then put
"_" for the file name as in the example above.
</p>
74 <p class=
"p2"><br></p>
75 <p class=
"p3">For details on other valid arguments to the scsynth app see
<a href=
"../ServerArchitecture/Server-Architecture.html"><span class=
"s5">Server-Architecture
</span></a>.
</p>
76 <p class=
"p2"><br></p>
77 <p class=
"p3">This could be executed in SC as:
</p>
78 <p class=
"p2"><br></p>
79 <p class=
"p4">"./scsynth -N Cmds.osc _ NRTout.aiff 44100 AIFF int16 -o 1"<span class=
"s1">.unixCmd;
</span><span class=
"s6">// -o
1 is mono output
</span></p>
80 <p class=
"p2"><br></p>
81 <p class=
"p3">A more powerful option is to use the
<b>Score
</b>object, which has convenience methods to create OSC command files and do nrt synthesis. See the
<a href=
"../Control/Score.html"><span class=
"s5">Score
</span></a><b> </b>helpfile for more details.
</p>
82 <p class=
"p2"><br></p>
83 <p class=
"p2"><br></p>
85 <p class=
"p7">x = [
</p>
86 <p class=
"p5"><br></p>
87 <p class=
"p7">[
0.0, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1000,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
1413 ]],
</p>
88 <p class=
"p7">[
0.1, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1001,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
712 ]],
</p>
89 <p class=
"p7">[
0.2, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1002,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
417 ]],
</p>
90 <p class=
"p7">[
0.3, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1003,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
1238 ]],
</p>
91 <p class=
"p7">[
0.4, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1004,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
996 ]],
</p>
92 <p class=
"p7">[
0.5, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1005,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
1320 ]],
</p>
93 <p class=
"p7">[
0.6, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1006,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
864 ]],
</p>
94 <p class=
"p7">[
0.7, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1007,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
1033 ]],
</p>
95 <p class=
"p7">[
0.8, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1008,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
1693 ]],
</p>
96 <p class=
"p7">[
0.9, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1009,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
410 ]],
</p>
97 <p class=
"p7">[
1.0, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1010,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
1349 ]],
</p>
98 <p class=
"p7">[
1.1, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1011,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
1449 ]],
</p>
99 <p class=
"p7">[
1.2, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1012,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
1603 ]],
</p>
100 <p class=
"p7">[
1.3, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1013,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
333 ]],
</p>
101 <p class=
"p7">[
1.4, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1014,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
678 ]],
</p>
102 <p class=
"p7">[
1.5, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1015,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
503 ]],
</p>
103 <p class=
"p7">[
1.6, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1016,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
820 ]],
</p>
104 <p class=
"p7">[
1.7, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1017,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
1599 ]],
</p>
105 <p class=
"p7">[
1.8, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1018,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
968 ]],
</p>
106 <p class=
"p7">[
1.9, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1019,
0,
0,
<span class=
"Apple-converted-space"> </span><span class=
"s3">\freq
</span>,
1347 ]],
</p>
107 <p class=
"p5"><br></p>
108 <p class=
"p7">[
3.0, [
<span class=
"s3">\c_set
</span>,
0,
0]]
<span class=
"Apple-converted-space"> </span></p>
111 <p class=
"p8"><br></p>
112 <p class=
"p3">You can then use Score.write to convert the above to the OSC command file as follows:
</p>
113 <p class=
"p2"><br></p>
114 <p class=
"p4"><span class=
"s2">Score
</span><span class=
"s1">.write(x,
</span>"score-test.osc"<span class=
"s1">);
</span></p>
115 <p class=
"p4">"./scsynth -N score-test.osc _ score-test.aiff 44100 AIFF int16 -o 1"<span class=
"s1">.unixCmd;
</span></p>
116 <p class=
"p2"><br></p>
117 <p class=
"p3">Score also provides methods to do nrt synthesis directly:
</p>
118 <p class=
"p5"><br></p>
120 <p class=
"p7"><span class=
"s2">var
</span> f, o;
</p>
121 <p class=
"p7">g = [
</p>
122 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[
0.1, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1000,
0,
0,
<span class=
"s3">\freq
</span>,
440]],
<span class=
"Apple-tab-span"> </span></p>
123 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[
0.2, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1001,
0,
0,
<span class=
"s3">\freq
</span>,
660]],
</p>
124 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[
0.3, [
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\NRTsine
</span>,
1002,
0,
0,
<span class=
"s3">\freq
</span>,
220]],
</p>
125 <p class=
"p7"><span class=
"Apple-tab-span"> </span>[
1, [
<span class=
"s3">\c_set
</span>,
0,
0]]
</p>
126 <p class=
"p7"><span class=
"Apple-tab-span"> </span>];
</p>
127 <p class=
"p7">o =
<span class=
"s2">ServerOptions
</span>.new.numOutputBusChannels =
1;
<span class=
"s6">// mono output
</span></p>
128 <p class=
"p4"><span class=
"s2">Score
</span><span class=
"s1">.recordNRT(g,
</span>"help-oscFile.osc"<span class=
"s1">,
</span>"helpNRT.aiff"<span class=
"s1">, options: o);
</span><span class=
"s6">// synthesize
</span></p>